package com.tank.tank;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class TankGame05 extends JFrame {
    private MyPanel mp=null;
    Scanner scanner=new Scanner(System.in);

    //主函数
    public static void main(String[] args) {
        new TankGame05();
    }
    //
    public TankGame05(){
        System.out.println("请选择1新游戏  2原游戏");
        int key=scanner.nextInt();

        mp=new MyPanel(key);
        Thread thread = new Thread(mp);
        thread.start();
        this.add(mp);//添加画板
        this.addKeyListener(mp);//让JFrame监听mp的键盘事件
        this.setSize(1300,750);
        this.setVisible(true);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                super.windowClosing(e);
                Recorder.keepRecord();
                System.exit(0);
            }
        });
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
